package com.ruoyi.qiandao.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qiandao.domain.Qiandao;
import com.ruoyi.qiandao.service.IQiandaoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工签到Controller
 * 
 * @author beilian
 * @date 2023-04-17
 */
@Controller
@RequestMapping("/qiandao/paibanTest")
public class QiandaoController extends BaseController
{
    private String prefix = "qiandao/paibanTest";

    @Autowired
    private IQiandaoService qiandaoService;

    @RequiresPermissions("qiandao:paibanTest:view")
    @GetMapping()
    public String paibanTest()
    {
        return prefix + "/paibanTest";
    }

    /**
     * 查询员工签到列表
     */
    @RequiresPermissions("qiandao:paibanTest:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Qiandao qiandao)
    {
        startPage();
        List<Qiandao> list = qiandaoService.selectQiandaoList(qiandao);
        return getDataTable(list);
    }

    /**
     * 导出员工签到列表
     */
    @RequiresPermissions("qiandao:paibanTest:export")
    @Log(title = "员工签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Qiandao qiandao)
    {
        List<Qiandao> list = qiandaoService.selectQiandaoList(qiandao);
        ExcelUtil<Qiandao> util = new ExcelUtil<Qiandao>(Qiandao.class);
        return util.exportExcel(list, "员工签到数据");
    }

    /**
     * 新增员工签到
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存员工签到
     */
    @RequiresPermissions("qiandao:paibanTest:add")
    @Log(title = "员工签到", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Qiandao qiandao)
    {
        return toAjax(qiandaoService.insertQiandao(qiandao));
    }

    /**
     * 修改员工签到
     */
    @RequiresPermissions("qiandao:paibanTest:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Qiandao qiandao = qiandaoService.selectQiandaoById(id);
        mmap.put("qiandao", qiandao);
        return prefix + "/edit";
    }

    /**
     * 修改保存员工签到
     */
    @RequiresPermissions("qiandao:paibanTest:edit")
    @Log(title = "员工签到", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Qiandao qiandao)
    {
        return toAjax(qiandaoService.updateQiandao(qiandao));
    }

    /**
     * 删除员工签到
     */
    @RequiresPermissions("qiandao:paibanTest:remove")
    @Log(title = "员工签到", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qiandaoService.deleteQiandaoByIds(ids));
    }
}
